import java.util.Scanner;

class BankAccount{
    int balance;

    public BankAccount() {
        balance = 0;
    }

    public BankAccount(int balance) {
        this.balance = balance;
    }

    public int getBalance() {
        return balance;
    }
    public void withdraw(int a){
        if (a <= balance){
            balance = balance - a;
        }else {
            System.out.println("Insufficient balance.");
        }
    }
    public void deposit(int a){
        balance = balance + a;
    }
}
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int balance = scanner.nextInt();
        BankAccount bankAccount = new BankAccount(balance);
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            String num = scanner.next();
            int money = scanner.nextInt();
            if (num.equals("d")){
                bankAccount.deposit(money);
                System.out.println("balance:" + bankAccount.getBalance());
            } else if (num.equals("w")) {
                bankAccount.withdraw(money);
                System.out.println("balance:" + bankAccount.getBalance());
            }
        }
    }
}